package com.wangxiang.shop.member.service.Impl;

import com.wangxiang.shop.member.entity.DevReceiptEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wangxiang.common.utils.PageUtils;
import com.wangxiang.common.utils.Query;

import com.wangxiang.shop.member.dao.LocaltionDao;
import com.wangxiang.shop.member.entity.LocaltionEntity;
import com.wangxiang.shop.member.service.LocaltionService;


@Service("localtionService")
public class LocaltionServiceImpl extends ServiceImpl<LocaltionDao, LocaltionEntity> implements LocaltionService {
    @Autowired
    private LocaltionDao localtionDao;

    @Override
    public List<DevReceiptEntity> province() {
        List<LocaltionEntity> localtionEntities = localtionDao.selectList(null);

        List<DevReceiptEntity> list = new ArrayList<>();
        for (LocaltionEntity localtionEntity : localtionEntities) {
            DevReceiptEntity devReceiptEntity = new DevReceiptEntity();

            if (localtionEntity.getParent().equals("1")){
                devReceiptEntity.setText(localtionEntity.getName());
                devReceiptEntity.setValue(localtionEntity.getTreeId());
                list.add(devReceiptEntity);
            }

        }

        return list;
    }

    @Override
    public List<DevReceiptEntity> city(String value) {
        List<LocaltionEntity> localtionEntities = localtionDao.selectList(null);
        List<DevReceiptEntity> list = new ArrayList<>();
        for (LocaltionEntity localtionEntity : localtionEntities) {
            DevReceiptEntity devReceiptEntity = new DevReceiptEntity();

            if (localtionEntity.getParent().equals(value)){
                devReceiptEntity.setText(localtionEntity.getName());
                devReceiptEntity.setValue(localtionEntity.getTreeId());
                list.add(devReceiptEntity);
            }

        }

        return list;
    }

    @Override
    public List<DevReceiptEntity> area(String value) {
        List<LocaltionEntity> localtionEntities = localtionDao.selectList(null);
        List<DevReceiptEntity> list = new ArrayList<>();
        for (LocaltionEntity localtionEntity : localtionEntities) {
            DevReceiptEntity devReceiptEntity = new DevReceiptEntity();

            if (localtionEntity.getParent().equals(value)){
                devReceiptEntity.setText(localtionEntity.getName());
                devReceiptEntity.setValue(localtionEntity.getTreeId());
                list.add(devReceiptEntity);
            }

        }

        return list;
    }
}